package com.bdqn.ch05SL.service.impl;


import com.bdqn.ch05SL.dao.UserDao;
import com.bdqn.ch05SL.factory.UserDaoFactory;
import com.bdqn.ch05SL.pojo.User;
import com.bdqn.ch05SL.service.UserService;

public class UserServiceImpl implements UserService {
    // 通过工厂获取所依赖的UserDao对象
    private UserDao userDao = UserDaoFactory.getInstance();
    /**
     * 保存用户信息
     *
     * @param user
     */
    @Override
    public void save(User user) {
        // 调用UserDao的方法保存用户信息
        userDao.save(user);
    }

    /**
     * dao属性的setter访问器，会被Spring调用，实现设值注入
     */
    public void setUserDao(UserDao userDao) {
           this.userDao = userDao;
    }
}
